/* 
 * File:   FractalPrinter.h
 * Author: amouro-m
 *
 * Created on 18 mai 2010, 09:36
 */

#ifndef _FRACTALPRINTER_H
#define	_FRACTALPRINTER_H

#include <SDL/SDL.h>

#include "tools.h"
#include "Fractal.hpp"

class FractalPrinter:public QObject
{
    Q_OBJECT
    
public:
    FractalPrinter(SDL_Surface* area);
    FractalPrinter(SDL_Surface* area, Fractal* fractal);
    virtual ~FractalPrinter();

    static void putpixel(SDL_Surface *surface, int x, int y, Uint32 color);
    static Uint32 getpixel(const SDL_Surface *surface, unsigned int x, unsigned int y);

    Fractal*    get_fractal() const;
    unsigned int get_width() const;
    unsigned int get_height() const;
    SDL_Surface* get_area() const;
    void set_fractal(Fractal* _fractal);

    void compute(unsigned int x, unsigned int y);
    void repaint();

signals:
    void updated();

protected:
    static const unsigned int _nb_point_added = 100;
    Fractal*    _fractal;
    SDL_Surface* _area;
    double      _coefx_to_area;
    double      _coefy_to_area;
    double      _coefx_to_fractal;
    double      _coefy_to_fractal;

private:
    virtual void update();
    virtual unsigned int coordX(double x) const;
    virtual unsigned int coordY(double y) const;
};

#endif	/* _FRACTALPRINTER_H */

